﻿using Manson.AuthorizationHelper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Manson.AuthorizationTool
{
    public partial class FrmAurhorizationTool : Form
    {
        public FrmAurhorizationTool()
        {
            InitializeComponent();
        }

        private void btn_Aurhorization_Click(object sender, EventArgs e)
        {
            if(txt_AuthorizationPath.Text .Length==0)
            {
                MessageBox.Show("请输入授权路径","软件授权");
                return;
            }
            if (txt_AuthorizationName.Text.Length == 0)
            {
                MessageBox.Show("请输入授权名称", "软件授权");
                return;
            }
            if (txt_AuthorizationCode.Text.Length == 0)
            {
                MessageBox.Show("请输入授权码", "软件授权");
                return;
            }
            try
            {
                Regedit.AddItem(this.txt_AuthorizationPath.Text .Trim(),this.txt_AuthorizationName.Text .Trim (),this.txt_AuthorizationCode.Text.Trim());
            }
            catch (Exception ex)
            {
                MessageBox.Show("授权失败："+ex.Message , "软件授权");
                return;
            }
            MessageBox.Show("授权注入成功,请测试！", "软件授权");
        }

        private void btn_Cancle_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btn_CPUCode_Click(object sender, EventArgs e)
        {
            string info = Authorization.GetComputerInfo();
            Clipboard.SetDataObject (info);
            MessageBox.Show("机器码已复制"+info,"机器码");
        }
    }
}
